﻿<controls:MetroWindow x:Class="ExchangeTracker.Presentation.MainWindow"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
                      xmlns:common="clr-namespace:ExchangeTracker.Presentation.Common"
                      ShowInTaskbar="True" WindowStartupLocation="CenterScreen" WindowState="Maximized"
                Title="{Binding Title}"
                DataContext="{Binding Source={StaticResource Locator}, Path=MainWindowViewModel}"
        FlowDirection="RightToLeft" FontFamily="{StaticResource FontFamily3}"
                      ShowIconOnTitleBar="True" Icon="/Assets/appbar.cogs.png"
                      Loaded="MainWindow_OnLoaded"
                      Closed="MainWindow_OnClosed"
                      Closing="MainWindow_OnClosing"
        >
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/colors.xaml" />
        <!--        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />-->
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.AnimatedSingleRowTabControl.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/Blue.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/baselight.xaml" />
        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/FlatButton.xaml" />
      </ResourceDictionary.MergedDictionaries>
      <!--<common:ContentVisibilityConverter x:Key="ContentVisibilityConverter" />-->
    </ResourceDictionary>
  </Window.Resources>
  <controls:MetroWindow.WindowCommands>
    <controls:WindowCommands>
      <Button Content="About" Click="ButtonBase_OnClick"/>
    </controls:WindowCommands>
  </controls:MetroWindow.WindowCommands>
  <controls:MetroContentControl>
    <Grid>
      <TabControl x:Name="TabMenu" ItemsSource="{Binding MenuCommandObjects}" SelectionChanged="Selector_OnSelectionChanged">
        <TabControl.ItemContainerStyle>
          <Style TargetType="TabItem"  BasedOn="{StaticResource {x:Type TabItem}}">
            <Setter Property="ContentTemplate">
              <Setter.Value>
                <DataTemplate>
                  <Grid Background="#42B1E1">
                    <Grid.RowDefinitions>
                      <RowDefinition Height="Auto"/>
                      <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <ItemsControl Grid.Row="0" Grid.Column="0" Focusable="False" ItemsSource="{Binding Navigator.DataContext.CommandObjects}" >
                      <ItemsControl.ItemTemplate>
                        <DataTemplate>
                          <Button Foreground="White" Style="{DynamicResource MetroCircleButtonStyle}" MinWidth="50" Height="50" Command="{Binding Command}" Content="{Binding Key,Converter={StaticResource ResourceConverter}}"/>
                        </DataTemplate>
                      </ItemsControl.ItemTemplate>
                      <ItemsControl.ItemsPanel>
                        <ItemsPanelTemplate>
                          <StackPanel Orientation="Horizontal"/>
                        </ItemsPanelTemplate>
                      </ItemsControl.ItemsPanel>
                    </ItemsControl>
                    <GroupBox Header="{Binding Navigator.DataContext.Title}" FontFamily="{StaticResource FontFamily2}" FontSize="{StaticResource FontSize0X}" Grid.Row="1" Grid.Column="0">
                      <GroupBox.HeaderTemplate>
                        <DataTemplate>
                          <TextBlock Text="{Binding}" FontSize="{StaticResource FontSize0X}" Height="5"></TextBlock>
                        </DataTemplate>
                      </GroupBox.HeaderTemplate>
                      <GroupBox.Resources>
                        <ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/mauve.xaml" />
                      </GroupBox.Resources>
                      <ContentControl Content="{Binding Navigator}"/>
                    </GroupBox>
                  </Grid>
                </DataTemplate>
              </Setter.Value>
            </Setter>
            <Setter Property="HeaderTemplate">
              <Setter.Value>
                <DataTemplate>
                  <TextBlock  Text="{Binding Path=DataContext.Key, 
                          RelativeSource={RelativeSource AncestorType={x:Type TabItem}}, 
                          Converter={StaticResource ResourceConverter}}"
                              Style="{StaticResource TabHeaderStyle}">
                  </TextBlock>
                </DataTemplate>
              </Setter.Value>
            </Setter>
          </Style>
        </TabControl.ItemContainerStyle>

      </TabControl>
      <!--      <ProgressBar Grid.Row="1" IsIndeterminate="True" HorizontalAlignment="Right" Width="100" Height="20" VerticalAlignment="Top"/>-->
    </Grid>
  </controls:MetroContentControl>
</controls:MetroWindow>
